fn main() {
    //panic!("firewall");   // 打印并异常退出
    test_none_in_vector();
}

fn  test_none_in_vector() {
    let fruits = vec!["banana", "apple", "orange"];

    let idx:[i32;3] = [0, 2, 99];
    /*
    for i in idx.iter() {
        match fruits.get(i) {   // get 方法会返回Option<T>
            Some(name) => println!("{}", name),
            None => println!("no such fruit"),
        }
    }
    */
    println!("{}", idx[0]);
    println!("{:?}", fruits.get(0));    
    println!("{:?}", fruits.get(1));
    println!("{:?}", fruits.get(2));
    //println!("{:?}", fruits.get(idx[0]));
}
